package com.woniuxy.microstockserver.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniuxy.microstockserver.bean.PageRequestBean;
import com.woniuxy.microstockserver.bean.StockBean;
import com.woniuxy.microstockserver.mapper.StockMapper;
import com.woniuxy.microstockserver.service.IStockService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author 赵雄伟
 * 库存impl
 */
@Service
public class StockServiceImpl implements IStockService {
    @Resource
    private StockMapper stockMapper;

    @Override
    public PageInfo<StockBean> findAllStockBean(PageRequestBean pageRequestBean, StockBean stockBean) {
        return PageHelper.startPage(pageRequestBean.getPageNum(),pageRequestBean.getLimit()).
                doSelectPageInfo(()->stockMapper.findAllStockBean(pageRequestBean, stockBean));
    }

    @Override
    public StockBean findByGoodsId(Long id) {
        return stockMapper.findByGoodsId(id);
    }

    @Override
    public int saveStockBean(StockBean stockBean) {
        return stockMapper.saveStockBean(stockBean);
    }

    @Override
    public int addStockBean(StockBean stockBean) {
        return stockMapper.addStockBean(stockBean);
    }

    @Override
    public int subStockBean(StockBean stockBean) {
        return stockMapper.subStockBean(stockBean);
    }

}
